package com.spring.aop;

import java.lang.reflect.Proxy;


@SuppressWarnings({"rawtypes", "unchecked"})
public class TestJDKProxy {


	public static void main(String[] args) {
		IHelloService helloService = new HelloService();

		/*Object obj = Proxy.newProxyInstance(TestJDKProxy.class.getClassLoader(), new Class[]{IHelloService.class}, new InvocationHandler() {
			@Override
			public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
				System.out.printf("---before--- \n");
				Object ret = method.invoke(helloService,args);
				return ret;
			}
		});*/

		IHelloService helloService1 = (IHelloService) Proxy.newProxyInstance(TestJDKProxy.class.getClassLoader(),new Class[]{IHelloService.class},(proxy, method, arg) -> {
			System.out.printf("---before--- \n");
			Object ret = method.invoke(helloService,arg);
			return ret;
		});

		helloService1.sayHello();
	}

}
